package com.tourism.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.tourism.dao.RoomDao;
import com.tourism.entity.Room;
import com.tourism.entity.RoomQuery;
import com.tourism.service.RoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description
 * @Author z
 * @Date 2021-04-25 15:54
 */
@Service
public class RoomServiceImpl implements RoomService {

    @Autowired
    private RoomDao roomDao;

    @Override
    public Room getRoomById(Long id) {
        return roomDao.getRoomById(id);
    }

    @Override
    public Boolean deleteRoomById(Long id) {
        return roomDao.deleteRoomById(id);
    }
//创建房型
    @Override
    public boolean addRoom(Room room) {
        room.init();
        return roomDao.addRoom(room);
    }
//修改房间
    @Override
    public boolean updateRoom(Room room) {
        return roomDao.updateRoom(room);
    }
//分页查询房间列表
    @Override
        public PageInfo<Room> getRoomList(RoomQuery roomQuery) {
        PageHelper.startPage(roomQuery.getPageNum(), roomQuery.getPageSize());
        List<Room> RoomList = roomDao.getRoomList(roomQuery);
        PageInfo<Room> result = new PageInfo<>(RoomList);
        return result;

    }


}
